﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ImportMFGsFromFile.AttributesManager
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.Generic;
using System.Linq;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ImportMFGsFromFile;

internal class AttributesManager
{
  private Dictionary<string, Dictionary<string, TxPlanningTypeFieldData>> attributesPerClass = new Dictionary<string, Dictionary<string, TxPlanningTypeFieldData>>();
  private Dictionary<string, HashSet<string>> invalidAttributesPerClass = new Dictionary<string, HashSet<string>>();

  public bool IsHandledAttribute(string className, string attributeName)
  {
    return this.attributesPerClass.ContainsKey(className) && this.attributesPerClass[className].ContainsKey(attributeName);
  }

  public bool IsInvalidAttribute(string className, string attributeName)
  {
    return this.invalidAttributesPerClass.ContainsKey(className) && this.invalidAttributesPerClass[className].Contains(attributeName);
  }

  public bool IsHandledRelationAttribute(string attributeName)
  {
    bool flag = false;
    Dictionary<string, HashSet<string>>.ValueCollection values = this.invalidAttributesPerClass.Values;
    for (int index = 0; !flag && index < values.Count; ++index)
      flag = values.ElementAt<HashSet<string>>(index).Contains(attributeName);
    return flag;
  }

  public TxPlanningTypeFieldData GetAttributeField(string className, string attributeName)
  {
    return !this.IsHandledAttribute(className, attributeName) ? (TxPlanningTypeFieldData) null : this.attributesPerClass[className][attributeName];
  }

  public void AddAttribute(
    string className,
    string attributeName,
    TxPlanningTypeFieldData attributeField)
  {
    if (!this.attributesPerClass.ContainsKey(className))
      this.attributesPerClass.Add(className, new Dictionary<string, TxPlanningTypeFieldData>());
    this.attributesPerClass[className].Add(attributeName, attributeField);
  }

  public void AddInvalidAttribute(string className, string attribute)
  {
    if (!this.invalidAttributesPerClass.ContainsKey(className))
      this.invalidAttributesPerClass.Add(className, new HashSet<string>());
    this.invalidAttributesPerClass[className].Add(attribute);
  }

  public void Clear()
  {
    this.attributesPerClass.Clear();
    this.invalidAttributesPerClass.Clear();
  }
}
